# Maintainer: Orhun Parmaksız <orhun@archlinux.org>
# Contributor: "Amhairghin" Oscar Garcia Amor (https://ogarcia.me)

pkgname=rpg-cli
pkgver=1.0.1
pkgrel=1
pkgdesc='Your filesystem as a dungeon!'
arch=('loong64' 'x86_64')
url='https://github.com/facundoolano/rpg-cli'
license=('MIT')
depends=('gcc-libs')
makedepends=('cargo')
source=("$pkgname-$pkgver.tar.gz::$url/archive/$pkgver.tar.gz"
        "$pkgname.sh")
sha256sums=('763d5a5c9219f2084d5ec6273911f84213e5424f127117ab0f1c611609663a8b'
            '0b70c8a7eaa33e91bfa7baabccbd6735bbb0dc330539bd16f9f316bb2c8dd515')

prepare() {
  cd "$pkgname-$pkgver"
  cargo fetch --locked --target "$CARCH-unknown-linux-gnu"
}

build() {
  cd "$pkgname-$pkgver"
  cargo build --frozen --release
}

check() {
  cd "$pkgname-$pkgver"
  cargo test --frozen
}

package() {
  cd "$pkgname-$pkgver"
  install -Dm 755 "target/release/$pkgname" -t "$pkgdir/usr/bin"
  install -Dm 644 README.md -t "$pkgdir/usr/share/doc/$pkgname"
  install -Dm 644 LICENSE -t "$pkgdir/usr/share/licenses/$pkgname"
  install -Dm 644 "../$pkgname.sh" "$pkgdir/usr/share/$pkgname/$pkgname.sh"
}
